package com.acwing.lc.part1;

/**
 * @author rkc
 * @date 2022/9/12 15:16
 */
public class LC35搜索插入位置 {

    public int searchInsert(int[] nums, int target) {
        int l = 0, r = nums.length - 1;
        while (l < r) {
            int mid = l + r >> 1;
            if (nums[mid] >= target) r = mid;
            else l = mid + 1;
        }
        if (nums[l] >= target) return l;
        return l + 1;
    }
}
